I'm testing the below in edge browser but I'm ultimately trying to get this to work inside an activex webbrowser contol on a form "shellExplorer.2"
I'm just trying to do this natively so I don't want jquery solution.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>JS Bin</title>
<script type="text/javascript">
function docode() {
console.log(document.activeElement.tagName);
}
</script>
</head>
<body onclick="docode();" contentEditable="true">
<div tabindex=1>Here</div>
<div>Nothing here</div>
<div contenteditable>Something here</div>
<table>
<tr>
<td> test text </td> <td> test 2</td>
</tr>
</table>
</body>
</html>
I have the above html. Ultimately I need to know which element is clicked on so I can find out if the element is inside a table for example. (my old code worked and I walk up the parentnodes until I hit a table or a body tag.
All I seem to get is "BODY". Sometimes I might be lucky and get a DIV for the div with a tabindex.
I have tried the following function and that just returns "undefined"
function docode() {
var ovar = window.getSelection();
var orange = ovar.getRangeAt(0);
console.log(orange.tagname);
}
The getSelection() and getRangeAt(0) used to work but it seems microsoft have changed something in the control.